﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace ComicsEditor
{
    public class Frame : EditableObject
    {
        public Rectangle Rectangle;

        public ActiveDashedRect DashedRect;
        public ColorRect ColorRect;

        public Frame(Page Page, Rectangle Rect, bool Visible) : base(Page)
        {
            Rectangle = Rect;

            ColorRect = new ColorRect(Page, Rect, Color.Blue, 3.0f);
            ColorRect.Strict = true;

            DashedRect = new ActiveDashedRect(Page, Rect);
            DashedRect.ActiveDashedRectChange += delegate(ActiveDashedRect activeDashedRect)
            {
                Rectangle = DashedRect.Rectangle;
                ColorRect.Rectangle = Rectangle;
            };
            DashedRect.Hide();

            if (!Visible)
                Hide();
        }

        public override void Dispose()
        {
            ColorRect.Dispose();
            DashedRect.Dispose();
            base.Dispose();
        }

        public override void Show()
        {
            base.Show();
            ColorRect.Show();
            if (Editing)
                DashedRect.Show();
        }

        public override void Hide()
        {
            base.Hide();
            ColorRect.Hide();
            DashedRect.Hide();
        }

        public override void BeginEdit()
        {
            base.BeginEdit();
            DashedRect.Show();
        }

        public override void EndEdit()
        {
            DashedRect.Hide();
            base.EndEdit();
        }
    }
}
